package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.BusinessCardRequest;
import one.stand.request.CallsPhoneRecordRequest;
import one.stand.request.TokenRequest;
import one.stand.request.UserCommonRequest;
import one.stand.response.BusinessCardResponse;
import one.stand.response.UserCommonResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("crmApi/businessCard")
@Api(description = "名片系列")
public class BusinessCardController extends BaseController {

    @ApiOperation(value = "获取公司员工")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "当前页", required = true, paramType = "Integer"),
    })
    @PostMapping("getCompanyStaffList")
    @ApiController(isLogin = true,company=true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Map<String, Object>> getCompanyStaffList(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.getCompanyStaffList(request);
    }

    @ApiOperation(value = "修改用户名片欢迎语")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "welcomeSpeech", value = "欢迎语", required = true, paramType = "String"),
            @ApiImplicitParam(name = "shareSpeech", value = "分享语", required = true, paramType = "String"),
    })
    @PostMapping("updateCardWelcomeSpeech")
    @ApiController(isLogin = true,company=true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Boolean> updateCardWelcomeSpeech(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.updateCardWelcomeSpeech(request);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "员工姓名", paramType = "Integer"),
    })
    @ApiOperation(value = "获取员工列表")
    @PostMapping("getList")
    @ApiController(isLogin = true, company = true,paramClass = BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> getList(@RequestAttribute BusinessCardRequest request){
        
        return crmFegin.getList(request);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "员工名片ID",paramType = "Integer"),
    })
    @ApiOperation(value = "获取员工详细信息")
    @PostMapping("getCompanyUserInfo")
    @ApiController(isLogin = true, company = true,paramClass = BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> getCompanyUserInfo(@RequestAttribute BusinessCardRequest request){
        
        return crmFegin.getCompanyUserInfo(request);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "员工名片ID",required = true,paramType = "Integer"),
    })
    @ApiOperation(value = "获取员工详细信息（中转）")
    @PostMapping("getCompanyUserInfoTransfer")
    @ApiController(paramClass = BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> getCompanyUserInfoTransfer(@RequestAttribute BusinessCardRequest request){
        if(request.getCardId() == null){
            return ResultModel.checkParamFail();
        }
        return crmFegin.getCompanyUserInfo(request);
    }

    @PostMapping("addCallsRecord")
    @ApiOperation(value = "添加通话记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "被拨打人名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass = CallsPhoneRecordRequest.class)
    public ResultModel addCallsRecord(@RequestAttribute CallsPhoneRecordRequest request) {
        
        return userFegin.addCallsRecord(request);
    }

    @PostMapping("getUserCard")
    @ApiOperation(value = "获取成员信息")
    @ApiImplicitParams({
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel getUserCard(@RequestAttribute BusinessCardRequest request) {
        
        return userFegin.getUserCard(request);
    }

    @ApiController(isLogin = true,company = true,card = true,paramClass = BusinessCardRequest.class)
    @PostMapping("updateCard")
    @ApiOperation(value = "修改名片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "style", value = "名片样式", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名", paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", paramType = "String"),
            @ApiImplicitParam(name = "logo", value = "头像url", paramType = "String"),
            @ApiImplicitParam(name = "personalWx", value = "个人微信", paramType = "String"),
            @ApiImplicitParam(name = "companyWx", value = "公司微信", paramType = "String"),
            @ApiImplicitParam(name = "photo", value = "个人照片集合（1.png,2.png,3.png）", paramType = "String"),
            @ApiImplicitParam(name = "position", value = "职位", paramType = "String"),
            @ApiImplicitParam(name = "soundRecording", value = "个人录音", paramType = "String"),
            @ApiImplicitParam(name = "soundTime", value = "录音时长", paramType = "Integer"),
            @ApiImplicitParam(name = "email", value = "邮箱", paramType = "String"),
            @ApiImplicitParam(name = "briefIntroduction", value = "个人简介", paramType = "String"),
    })
    public ResultModel<Boolean> updateCard(@RequestAttribute BusinessCardRequest request) {
        return userFegin.updateCard(request);
    }

    @PostMapping("getCardPoster")
    @ApiOperation(value = "得到名片海报")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel getCardPoster(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.getCardPoster(request);
    }

    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    @PostMapping("createCard")
    @ApiOperation(value = "创建名片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "style", value = "名片样式", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id",required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名",required = true, paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话",required = true, paramType = "String"),
            @ApiImplicitParam(name = "logo", value = "头像url", paramType = "String"),
            @ApiImplicitParam(name = "personalWx", value = "个人微信",required = true, paramType = "String"),
            @ApiImplicitParam(name = "companyWx", value = "公司微信", paramType = "String"),
            @ApiImplicitParam(name = "photo", value = "个人照片集合（1.png,2.png,3.png）", paramType = "String"),
            @ApiImplicitParam(name = "position", value = "职位", paramType = "String"),
            @ApiImplicitParam(name = "soundRecording", value = "个人录音", paramType = "String"),
            @ApiImplicitParam(name = "soundTime", value = "录音时长", paramType = "Integer"),
            @ApiImplicitParam(name = "email", value = "邮箱", paramType = "String"),
            @ApiImplicitParam(name = "briefIntroduction", value = "个人简介", paramType = "String"),
            @ApiImplicitParam(name = "password", value = "公司口令", paramType = "String"),
    })
    public ResultModel<Boolean> createCard(@RequestAttribute BusinessCardRequest request) {
        return userFegin.createCard(request);
    }

    @ApiController(isLogin = true,isParam = false)
    @PostMapping("isCreateCompany")
    @ApiOperation(value = "判断是否有名片或者公司")
    public ResultModel<Boolean> isCreateCompany(@RequestAttribute TokenRequest tokenRequest) {
        return userFegin.isCreateCompany(tokenRequest);
    }

    @PostMapping("getWxTwoCode")
    @ApiOperation(value = "得到名片二维码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel getWxTwoCode(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.getWxTwoCode(request);
    }

    @PostMapping("/verifyExpired")
    @ApiOperation(value = "验证名片是否过期")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Long> verifyExpired(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.verifyExpired(request);
    }

    @PostMapping("/formIdCount")
    @ApiOperation(value = "用户可接收微信推送次数")
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Integer> formIdCount(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.formIdCount(request);
    }

    @PostMapping("/delFormId")
    @ApiOperation(value = "清空微信推送次数")
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Boolean> delFormId(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.delFormId(request);
    }

    @PostMapping("/selectUserCommonList")
    @ApiOperation(value = "查询用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1用户端，2crm端", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = UserCommonRequest.class)
    public ResultModel<List<UserCommonResponse>> selectUserCommonList(@RequestAttribute UserCommonRequest request) {
        return crmFegin.selectUserCommonList(request);
    }

    @PostMapping("/insertUserCommonList")
    @ApiOperation(value = "新增/修改用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", paramType = "Integer"),
            @ApiImplicitParam(name = "text", value = "内容", required = true, paramType = "String"),
            @ApiImplicitParam(name = "type", value = "1用户端，2crm端", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> insertUserCommonList(@RequestAttribute UserCommonRequest request) {
        return crmFegin.insertUserCommonList(request);
    }

    @PostMapping("/delUserCommonList")
    @ApiOperation(value = "删除用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> delUserCommonList(@RequestAttribute UserCommonRequest request) {
        return crmFegin.delUserCommonList(request);
    }



    @PostMapping("/moveUserCommon")
    @ApiOperation(value = "上下移动用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "moveType", value = "1上移，2下移", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "type", value = "1用户端，2crm端", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> moveUserCommon(@RequestAttribute UserCommonRequest request) {
        return crmFegin.moveUserCommon(request);
    }

}
